<!-- 编辑弹窗 -->
<template>
    <ele-modal
      width="70%"
      :visible="visible"
      :close-on-click-modal="true"
      custom-class="ele-dialog-form"
      title="订单详情"
      @update:visible="updateVisible"
    >
    <el-form ref="form" :model="form" :rules="rules" label-width="100px" >
        <el-card  style="margin-top: -10px">
            <div slot="header" class="clearfix">
                <span style="font:bold">基本信息</span>
            </div>
            <el-row :gutter="20">
                <el-col :md="8" :sm="24">
                    <el-form-item label="订单编号:">
                        {{form.orderNo}}
                    </el-form-item>
                  </el-col>
                  <el-col :md="8" :sm="24">
                    <el-form-item label="下单时间:">
                        {{form.orderTime}}
                    </el-form-item>
                  </el-col>
                  <el-col :md="8" :sm="24">
                    <el-form-item label="状态:">
                       {{form.statusDesc}}
                    </el-form-item>
                  </el-col>
                
                 

              </el-row>
              <el-row>
                <el-col :md="8" :sm="24">
                  <el-form-item label="下单人:">
                      {{form.customerName}}({{form.customerPhone}})
                  </el-form-item>
                </el-col>
        
                <el-col :md="8" :sm="24">
                  <el-form-item label="订单金额:">{{form.totalPrice}}
                   
                  </el-form-item>
                </el-col>
                <el-col :md="8" :sm="24">
                  <el-form-item label="产品数量:" prop="disPrice">
                    {{form.productQty}}
                  </el-form-item>
                </el-col>
              </el-row>
             
      
              <el-row :gutter="24">
                <el-col :md="24" :sm="24">
                  <el-card style="margin-top: 10px">
                      <div slot="header" class="clearfix">
                          <span style="font:bold">商品信息</span>
                      </div>
                      <el-table :data="form.productList" :border="true" style="width: 100%">
                          <el-table-column type="index" width="50" align="center" label="序号" />
                          <el-table-column label="产品编号">
                            <template slot-scope="{ row }">
                                <span>{{ row.productCode }}</span>
                            </template>
                          </el-table-column>
                          <el-table-column label="产品名称">
                            <template slot-scope="{ row }">
                                <span>{{ row.productName }}</span>
                            </template>
                          </el-table-column>
                          
                          <el-table-column label="规格">
                              <template slot-scope="{ row }">
                                <span>{{ row.productItemName }}</span>
                              </template>
                          </el-table-column>
                         
                          <el-table-column label="单价">
                            <template slot-scope="{ row }">
                            <span>{{ row.price }}</span>
                          </template>
                          </el-table-column>
                         
                          <el-table-column label="数量">
                            <template slot-scope="{row}">
                                <span>{{ row.qty }}</span> 
                          </template>
                           
                        </el-table-column>
                        
                 
                      
                        <el-table-column label="单位">
                            <template slot-scope="{ row }">
                              <span>{{ row.unitName }}</span>
                            </template>
                        </el-table-column>
                      </el-table>
                  </el-card>
                </el-col>
               
            </el-row>
            
        </el-card>
        <el-card >
            <div slot="header" class="clearfix">
                <span style="font:bold">收货人信息</span>
            </div>
            <el-row :gutter="20">
                <el-col :md="6" :sm="24">
                    <el-form-item label="收货人:"  prop="receiver">{{form.orderReceipt.receiver}}
                       
                    </el-form-item>
                  </el-col>
                  <el-col :md="6" :sm="24"  >
                    <el-form-item label="收货人电话:" prop="phone">{{form.orderReceipt.phone}}
                      
                    </el-form-item>
                  </el-col>
                  <el-col :md="12" :sm="24" >
                    <el-form-item label="详细地址:" prop="address">{{form.orderReceipt.area}}{{form.orderReceipt.address}}
                      
                    </el-form-item>
                  </el-col>
              </el-row>
             
        </el-card>
        <el-card >
            <div slot="header" class="clearfix">
                <span style="font:bold">配送信息</span>
            </div>
            <el-row :gutter="20">
              <el-col :md="6" :sm="24">
                <el-form-item label="配送平台:" >{{form.delivery!=null?form.delivery.deliveryPlatform:''}}
                   
                </el-form-item>
              </el-col>
              
                  <el-col :md="6" :sm="24"  >
                    <el-form-item label="配送单号:" >{{form.delivery!=null?form.delivery.deliveryNo:''}}
                      
                    </el-form-item>
                  </el-col>
                  <el-col :md="6" :sm="24" >
                    <el-form-item label="配送人:" >{{form.delivery!=null?form.delivery.DeliveryUserName:''}}
                        
                    </el-form-item>
                  </el-col>
                  <el-col :md="6" :sm="24" >
                    <el-form-item label="配送电话:" >{{form.delivery!=null?form.delivery.deliveryPhone:''}}
                        
                    </el-form-item>
                  </el-col>
              </el-row>
             
        </el-card>
       
    </el-form>
    <div slot="footer">
      <el-button @click="updateVisible(false)">取消</el-button>
   
    </div>
    </ele-modal>
  </template>
  
  <script>
    //初始化对像
    import { printThis } from 'ele-admin';
    import { QueryOrderViewById} from '@/api/ordermanager/orderlist';
    export default {
      name: 'OrderEdit',
      props: {
        // 弹窗是否打开
        visible: Boolean,
        // 修改回显的数据
        data: Object,
        
      },
      data() {
        return {
          // 表单数据
          form: {
            productList:[],
            orderReceipt:{} ,
            delivery:{}
          },
          // 表单验证规则
          rules: {
           
          },
          // 提交状态
          loading: false,
          // 是否是修改
          isUpdate: false,
        };
      },
      created(){
      
      },
      methods: {
        doPrint() {
                printThis();  // 打印当前页面

                // 也可以设置一些参数
                /*printThis({
                    horizontal: false, // 是否横向打印
                    blank: false // 是否打开新页面打印
                });*/
            },
 
        setData(id){
          QueryOrderViewById(id)
            .then((res) => {
              this.form=res;
              //this.$util.assignObject(this.form, {...res});
               
           });
        },
        /* 更新visible */
        updateVisible(value) {
          //更新父组件中的visible的值
          this.$emit('update:visible', value);
          //更新文件列表对像
        },
      },  
      /* 监听visible属性变化 */
      watch: {
        visible(visible) {
          if (visible) {
            if (this.data && this.data.id) {
              //赋值this.form
              this.form={ productList:[],  orderReceipt:{}, delivery:{} };
              this.setData(this.data.id);
              this.isUpdate = this.isUpdate = this.data.id !=null && this.data.id !=undefined;
            } else {
              this.form={productList:[],  orderReceipt:{}, delivery:{}}
              this.isUpdate = false;
            }
          } else {
            //移除校验结果
            this.$refs['form'].clearValidate();
            this.form = {productList:[],  orderReceipt:{},delivery:{}};
          }
        }
      }
    };
  </script>
  